package com.qlshouyu.len41.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * TODO
 *
 * @author 高露 邮箱：<a href="egojit@qq.com">egojit@qq.com</a>
 * @since 2019-10-27 08:02
 */
//@Order(-1000)
//@WebFilter(urlPatterns = "/api/*", filterName = "appFilter")
public class AppFilter extends OncePerRequestFilter {
    private final static Logger LOGGER= LoggerFactory.getLogger(AppFilter.class);
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        String auth= request.getHeader("auth");
        if(!StringUtils.isEmpty(auth)){
            if("123".equals(auth)){
                LOGGER.debug("认证通过");
                filterChain.doFilter(request,response);
            }
        }
        LOGGER.debug("认证不通过");
        return;
    }
}
